﻿using Castle.ActiveRecord;

namespace LazyTests {
    [ActiveRecord]
    public class SystemUser : ActiveRecordBase<SystemUser> {
        [PrimaryKey, ValidateIsUnique]
        public int Id { get; set; }

        [Property, ValidateIsUnique]
        public string Name { get; set; }

        [Property("Passwort")]
        public string Password { get; set; }

        public static SystemUser FindById(int id) {
            return Find(id);
        }

        public static SystemUser FindByName(string pName) {
            var myUsers = FindAllByProperty("Name", pName);
            if (myUsers.Length != 0) {
                return myUsers[0];
            }
            return null;
        }
    }
}